import '@css/detailsPage.css'
import { insuranceListApi, searnameApi } from "@utils/api/productPage"
window.addEventListener('DOMContentLoaded', async () => {
    var tt = decodeURI(window.location)
    let detailName = tt.split("=")[1]
    console.log(detailName);
    const { rows } = await searnameApi(detailName)
    console.log(rows[0].insurancesName)
    particularsList(rows)
    document.querySelector('#photo').innerHTML = `<img src="${rows[0].insurancephoto}">`
    document.querySelector('.information').innerHTML = `泰康优选>${rows[0].insurancesName}(互联网版)`

    document.querySelector('.promptly').addEventListener('click', async (e) => {
        const name = rows[0].insurancesName
        window.location.href = `insurePage.html?name=${name}`
    })
})
const particularsList = (rows) => {
    document.querySelector('.particulars').innerHTML = `<div class="particulars-left">
     <p class="apply">适用人群:<span>${rows[0].insurancesSuitableFor}</span></p>
     <p class="scope">销售范围:<span>中国大陆（除港澳台地区）</span></p>
     <p class="duty">保险责任:<span>请阅读<a href="">平安中老年人医疗保险 (互联网版)适用条款</a>,并敬请特别留意条款中的“责任免除”“释义”部分。</span></p>
     <p class="deadline">保险期限:<span>${rows[0].insurancesPayType}</span></p>
     <p class="form">保单形式:<span>${rows[0].insurancesPolicy}</span></p>
    </div>
    <div class="particulars-right">
      <p class="price">￥${rows[0].insurancesPrice}起</p>
      <button class="promptly">立即投保>></button>
    </div>
    `
}